home *** CD-ROM | disk | FTP | other *** search
- Path: loki.tor.hookup.net!news
- From: Rajendra_Singh@msn.com (Rajendra Singh)
- Newsgroups: comp.lang.c
- Subject: Re: Beginer C please help me
- Date: Thu, 21 Mar 1996 04:58:33 GMT
- Organization: HookUp Communication Corporation, Oakville, Ontario, CANADA
- Message-ID: <4iqd15$ajd@loki.tor.hookup.net>
- References: <DoLCFx.B7x.0.bloor@torfree.net>
- NNTP-Posting-Host: u36u400.tor.hookup.net
- NNTP-Posting-User: u36u400
- X-Newsreader: Forte Free Agent 1.0.82
-
- bz786@torfree.net (Sherif Asif) wrote:
-
- >This may be a stupid mistake but "please help" me.
- >Thank you very much.
-
- >#include <stdio.h>
- >#include <math.h>
- >main ()
- >{
- >float n;
- >n=(9/5);
- >printf ("n= %1.3f\n", n);
- >}
- >I have complied and run the programme & I got the answer n=1.000
- >but Iam supposed to get answer 1.8.
- >Why I got this answer?
-
- You are dividing an integer by an integer, hence the result is an
- integer. Change one or both of the operands to a float, i. e. change
- 9 to 9. and/or 5 to 5., and you will get the desired result.
- ---
- Rajendra Singh, B. Sc. (Rajendra_Singh@msn.com)
- "What is understood need not be discussed." - Loren Adams
-
-